import { defineConfig } from 'vite' // 动态配置函数
import { createVuePlugin } from 'vite-plugin-vue2'
import { resolve } from 'path'

export default () =>
	defineConfig({
		plugins: [createVuePlugin()],
		server: {
			open: true, //自动打开浏览器
			port: 1567, //端口号
			proxy: {
				'/api': {
				  target: 'http://127.0.0.1:7001',
				  changeOrigin: true,
				  rewrite: (path) => path.replace(/^\/api/, '/api'),
				},
			  },
		},
		resolve: {
            // 别名
			alias: [
				{
					find: '@',
					replacement: '/src'
				}
			]
		}
	})

